﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
	Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Demo</title>
	<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
	<link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">编码</label>
					<div class="layui-input-block">
						<input type="text" id="resourceNo" placeholder="请输入" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" id="resourceName" placeholder="请输入" class="layui-input">
					</div>

				</div>

				<div class="layui-inline">
					<label class="layui-form-label">资源类别</label>
					<div class="layui-input-block">
						<select id="resourceType" lay-filter="testSelect2">
							<option value="">请选择</option>
							<option value="设备">设备</option>
							<option value="金额">金额</option>
							<option value="杂项">杂项</option>
							<option value="人员">人员</option>
						</select>
					</div>
				</div>

				<div class="layui-inline">
					<label class="layui-form-label">状态</label>
					<div class="layui-input-block">
						<select id="resourceSmark" lay-filter="testSelect2">
							<option value="0">请选择</option>
							<option value="1">有效</option>
							<option value="2">无效</option>
						</select>
					</div>
				</div>
				<div class="layui-inline">
					<button class="layui-btn" lay-submit lay-filter="search">
						查询
					</button>
				</div>
				<button type="button" class="layui-btn layui-bg-red" lay-on="test-iframe-curl" onclick="AddPermission()">+新增</button>
			</div>
		</div>
		
		
	</form>
	<table class="layui-hide" id="ID-table-demo-search"></table>
	<script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
	
	<script>
		 layui.use('table',function () {
			var form = layui.form;
			var layer = layui.layer;
			var laydate = layui.laydate;
			var util = layui.util;
			var table = layui.table;

			  var formData = {
				resourceNo: "",
				resourceName: "",
				resourceType:""
		


			};

			Seach()
			// 搜索提交
			function Seach() {
				// console.log(formData);
				// var rolesUrl = '@ViewBag.RBACWrite' + "/api/Resource/ShowResour?resourceNo=" + formData.resourceNo + '&resourceName=' + formData.resourceName + '&resourceType=' + formData.resourceType;
				$.ajax({
					url: '@ViewBag.RBACWrite' + "/api/Resource/ShowResour",
					type: 'post',
					dataType: "json",
					contentType: "application/json",
					success: res => {
						table.render({
							elem: '#ID-table-demo-search',
							cols: [[
								{field:'resourceId', width:120, title: '序号', sort: true},
								{field:'resourceNo', width:120, title: '资源编码'},
								{field:'resourceName', width:120, title: '资源名称'},
								{field:'resourceType', width:120, title: '资源类别'},
								{field:'resourceDw', width:120, title: '资源单位'},
								{field:'resourceMoney', width:120, title: '计算成本'},
								{field:'moneyType', width:120, title: '计费方式'},
								{field:'resourceCost', width:120, title: '费用类型'},
								{field:'resourceSmark', width:120, title: '状态'},
								{field:'', width:150, title: '操作'}
							]],
							data: res.data,
							page: true,
							limits: [2, 3, 4],
							height: 310
						});
						return;

					}
				});
			};

			 form.on('submit(search)', function (data) {
				var field = data.field; // 获取表单字段值
				// 显示填写结果，仅作演示用
				formData.resourceNo = $("#resourceNo").val();
				formData.resourceName = $("#resourceName").val();
				formData.resourceType = $("#resourceType").val()
				Seach();
				return false; // 阻止默认 form 跳转
			});
		});

		function AddPermission(){
			location.href='SourcesAdd'
		}
	</script>

</body>
</html>



